package com.vy.stl.mapper;

import com.vy.stl.entity.Reserve;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @create: 2025/08/30 10:02
 * @description:
 */
public interface ReserveMapper {
    /**
     * 根据会员id查询预约信息
     * @param memberId
     * @return
     */
    List<Reserve> selectByMemberId(@Param("memberId") Integer memberId);

    /**
     * 根据课程id查询预约信息
     * @param id
     * @return
     */
    List<Reserve> selectByCourseId(@Param("courseId") Integer id);

    /**
     * 查询预约列表
     * @param reserve
     * @return
     */
    List<Reserve> select(Reserve reserve);

    /**
     * 根据会员id和课程id查询预约信息
     * @param reserve
     * @return
     */
    Reserve selectByMemberIdAndCourseId(Reserve reserve);

    /**
     * 添加预约信息
     * @param reserve
     * @return
     */
    int insert(Reserve reserve);

    /**
     * 修改预约信息
     * @param reserve
     * @return
     */
    int edit(Reserve reserve);


    @Update("<script>" +
            "<foreach collection='list' item='item' separator=';'>" +
            "UPDATE reserve " +
            "SET status = #{item.status} " +  // 只更新存在的status字段
            "WHERE id = #{item.id} " +
            "</foreach>" +
            "</script>")
    int batchUpdateStatus(@Param("list") List<Reserve> reserveList);
}
